<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<?php
session_start();
if ($_SESSION["member"] == null)
    header("location:../web/index.php");
?>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Home</title>
        <style type="text/css">
            .body {
				font-family: "Arial Black", Gadget, sans-serif;
				font-size: 12px;
				font-style: normal;
				color: #000;	
            }
			.header {
				background-image:url(../web/img/panel.png);
				background-repeat:no-repeat;
				background-size:100%;
				max-height:400px;
				min-height:400px;
				height:400px;
			}
            .main_form {
                width: 800px;
                margin-right: auto;
                margin-left: auto;
            }

            .content {
                background-color:#FFF;
            }

            .left_content {
                width:580px;
                float:left;
            }

            .add_status {
                width:580px;
                height:50px;
				margin-top:10px;
                background-image:url(../web/img/status_bar.png);
                background-repeat:repeat-x;
            }

            .label_status {
                margin-left:20px;
                color:#FFF;
                font-size:14px;
            }

            .input_status {
                height:25px;
                width:300px;
                margin-left:10px;
                margin-right:10px;
                margin-top:10px;
            }

            .button_post {
				background-color: rgba(0, 0, 0, 0);
				background-image: -webkit-linear-gradient(top, rgb(255, 255, 255) 0px, rgb(221, 221, 221) 100%);
				background-repeat: repeat-x;
				border-bottom-color: rgb(5, 126, 208);
				border-bottom-left-radius: 4px;
				border-bottom-right-radius: 4px;
				border-bottom-style: solid;
				border-bottom-width: 1px;
				border-left-color: rgb(5, 126, 208);
				border-left-style: solid;
				border-left-width: 1px;
				border-right-color: rgb(5, 126, 208);
				border-right-style: solid;
				border-right-width: 1px;
				border-top-color: rgb(5, 126, 208);
				border-top-left-radius: 4px;
				border-top-right-radius: 4px;
				border-top-style: solid;
				border-top-width: 1px;
				box-sizing: border-box;
				color: rgb(1, 154, 210);
				cursor: pointer;
				display: block;
				float: right;
				font-family: 'Helvetica Neue', Arial, sans-serif;
				font-size: 13px;
				font-weight: bold;				
				letter-spacing: normal;
				line-height: 18px;
				margin-bottom: 0px;
				margin-left: 0px;
				margin-right: 0px;
				margin-top: 0px;
				padding-bottom: 5px;
				padding-left: 10px;
				padding-right: 10px;
				padding-top: 5px;
				position: relative;
				text-align: center;
				text-indent: 0px;
				text-shadow: rgba(0, 0, 0, 0.247059) 0px -1px 1px;
				text-transform: none;
				white-space: nowrap;
				width: 110px;
				word-spacing: 0px;
				writing-mode: lr-tb;
				margin-right:20px;
				font-size:15px;
				margin-top:10px;
				height: 30px;
            }

            .button_post:hover {
                background-color: rgba(245, 245, 245);
				background-image: -webkit-linear-gradient(top, rgb(236, 235, 235) 0px, rgb(197, 192, 192) 100%);
            }

            .button_post:active {
                background-color: rgba(0, 0, 0, 0);
				background-image: -webkit-linear-gradient(top, rgb(255, 255, 255) 0px, rgb(221, 221, 221) 100%);
            }

            .control_bar {
                width:800px;
                height:50px;
				margin-left:auto;
				margin-right:auto;
            }

            .button_control {
                -webkit-appearance: none;
				-webkit-border-image: none;
				-webkit-box-align: center;
				-webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px 0px;
				-webkit-writing-mode: horizontal-tb;
				background-color: rgb(1, 154, 210);
				background-image: linear-gradient(rgb(51, 188, 239), rgb(1, 154, 210));
				background-repeat: repeat-x;
				border-bottom-color: rgb(5, 126, 208);
				border-bottom-style: solid;
				border-bottom-width: 1px;
				border-collapse: collapse;
				border-left-color: rgb(5, 126, 208);
				border-left-style: solid;
				border-left-width: 1px;
				border-right-color: rgb(5, 126, 208);
				border-right-style: solid;
				border-right-width: 1px;
				border-top-color: rgb(5, 126, 208);
				border-top-style: solid;
				border-top-width: 1px;
				box-shadow: rgb(255, 255, 255) 0px 1px 0px 0px;
				box-sizing: border-box;
				cursor: pointer;
				display: block;
				float: right;
				font-family: 'Helvetica Neue', Arial, sans-serif;
				font-size: 13px;
				font-weight: bold;				
				letter-spacing: normal;
				line-height: 18px;
				padding-bottom: 5px;
				padding-left: 10px;
				padding-right: 10px;
				padding-top: 5px;
				position: relative;
				text-align: center;
				text-indent: 0px;
				text-shadow: rgba(0, 0, 0, 0.247059) 0px -1px 1px;
				text-transform: none;
				white-space: nowrap;
				width: 200px;
				height: 40px;
				word-spacing: 0px;
				writing-mode: lr-tb;				
            }
			.button_control a {
			color:#FFF;
			font-size:14px;
			}

            .button_control:hover {
                background-color: rgb(8, 128, 172);
				background-image: linear-gradient(rgb(18, 161, 214), rgb(4, 119, 162));
            }

            .button_control:active {
                background-color: rgb(1, 154, 210);
				background-image: linear-gradient(rgb(51, 188, 239), rgb(1, 154, 210));
            }

            .status_list {
                margin-top:10px;
                width:600px;
            }

            .table_status {
                width:580px;
				background-color: rgba(0, 0, 0, 0);
				background-image: -webkit-linear-gradient(top, rgb(255, 255, 255) 0px, rgb(221, 221, 221) 100%);
				background-repeat: repeat-x;
            }

            .row_name {
                width:160px;
                font-size:16px;
                font-weight:bold;
                padding-top:5px;
                padding-left:5px;
                padding-bottom:5px;
                border-bottom:solid #096d99 1px;
                border-left:solid #096d99 1px;
                border-top:solid #096d99 1px;
				margin-bottom:2px;
            }

            .row_status {
                width:400px;
                font-size:16px;
                padding-top:5px;
                padding-left:5px;
                padding-bottom:5px;
                border-bottom:solid #096d99 1px;
                border-right:solid #096d99 1px;
                border-top:solid #096d99 1px;
            }

            .right_content {
                width:200px;
                margin-left:600px;
            }

            .title_friend {
                background-image:url(../web/img/status_bar.png);
                background-repeat:repeat-x;
                width:190px;
                height:25px;
                color:#FFF;
                font-weight:bold;
                font-size:16px;
                margin-top:10px;
                padding-top:5px;
                padding-left:10px;
            }

            .friend_list {
                width: 198px;
                border-left:solid #096d99 1px;
                border-right:solid #096d99 1px;
            }

            .table_friend {
                width:198px;
                margin-left:1px;
            }

            .row_friend {	
                font-size: 14px;
                font-weight:bold;
                color: #30F;
                border-bottom:dotted #096d99 1px;
                padding:5px;
            }

            .row_online {
                width:30px;
                height:10px;
                background-image:url(../web/img/onl.png);
                background-repeat:no-repeat;	
                background-position:center;
                border-bottom:dotted #096d99 1px;
            }

            .row_offline {
                width:30px;
                height:10px;
                background-image:url(../web/img/off.png);
                background-repeat:no-repeat;	
                background-position:center;
                border-bottom:dotted #096d99 1px;
            }

            .footer_friend {
                background-image:url(../web/img/status_bar.png);
                background-repeat:repeat-x;
                width:200px;
                height:20px;	
            }
            a{
                text-decoration: none;                
            }
			.username {
			font-size:20px;
			padding-top: 5px;
			padding-bottom:5px;
			color:rgb(19, 136, 210);
			}
			.personal_info {
			font-size: 14px;
			font-style:normal;
			padding-left: 10px;
			padding-bottom:2px;
			}
			.status_item {
			width:560px;
			background-color: rgba(240, 240, 240);
			background-image: -webkit-linear-gradient(top, rgb(226, 233, 236) 0px, rgb(201, 219, 225) 100%);
			background-repeat: repeat-x;
			border-bottom-left-radius: 5px;
			border-bottom-right-radius: 5px;
			border-top-left-radius: 5px;
			border-top-right-radius: 5px;
			padding-top: 5px;
			padding-bottom:5px;
			padding-left:10px;
			padding-right:10px;
			margin-bottom:10px;
			min-height:50px;
			}
			.status_item_left {
			width:180px;
			float:left;
			}
			.status_item_user {
			font-size:14px;
			color: rgb(94, 167, 213);
			}
			.status_item_date {
			font-size:12px;
			color:#999;
			}
			.status_item_right {
			width:380px;
			margin-left:180px;
			font-size:13px;
			padding:5px;
			}
        </style>
        <script type="text/javascript">
            function CheckPostMessager() {
                var mesages = document.getElementsByName("ipmessage")[0].value;
                if (mesages == "") {
                    alert("can't blank messager");
                    return false;
                }
                else {
                    return true;
                }
            }
        </script>
    </head>

    <body class="body">
    	<div class="header"></div>
        <div class="control_bar">
        	<div class="control_bar">
            	<button class="button_control"><a href="home.php">Refresh</a></button>
                <button class="button_control"><a href="edituser.php">Edit Profile</a></button>
                <button class="button_control"><a href="listuser.php">Add friend</a></button>
                <button class="button_control"><a href="../bus/logout.php">Sign out</a></button>
            </div>
        </div>
        <div class="main_form">        	
            <div class="content">
            	<div>
                    <?php
                    require_once '../dao/membersdao.php';
                        $member = membersdao::GetMembersByID($_SESSION["Name"]);
                        print "<div class='username'>".$member->getUserID()."</div>";
                        print "<div class='personal_info'>Age: ".$member->getAge()."</div>";
                        switch ($member->getStatus()) {
                            case 0:
                                print "<div class='personal_info'>Status: Single</div>";
                                break;
                            case 1:
                                print "<div class='personal_info'>Status: Married</div>";
                                break;
                            case 2: 
                                print "<div class='personal_info'>Status: Relationship</div>";
                                break;
                            default:
                                break;
                        }
                        if($member->getGender())
                            print "<div class='personal_info'>Gender: Male</div>";
                        else{
                            print "<div class='personal_info'>Gender: Female</div>";
                        }
                        print "<div class='personal_info'>Email: ".$member->getEmail()."</div>";
                        print "<div class='personal_info'>Location: ".$member->getLocation()."</div>";
                    ?>
                </div>
                <div class="left_content">                    
                    <div class="add_status">
                        <form action="../bus/postmessage.php" name="statusform" onsubmit="return CheckPostMessager();" method="post">
                            <label class="label_status" for="ipmessage">Write status:</label>
                            <input class="input_status" name="ipmessage"></input>
                            <input type="submit" class="button_post" value="Post"></input>
                        </form>
                    </div>                    
                    <div class="status_list">
                    	<?php
                        require_once '../dao/messagersdao.php';
                        require_once '../dto/messagerdto.php';
                        $lstmessages = messagersdao::getAllMessages($_SESSION["Name"]);
                        for ($i = 0; $i < count($lstmessages); $i++) {
				print "<div class='status_item'>";
                        	print "<div class='status_item_left'>";
                            	print "<div class='status_item_user'>".$lstmessages[$i]->getUserID()."</div>";
                                print "<div class='status_item_date'>" . $lstmessages[$i]->getDatePost() . "</div>";
                            print "</div>";
                            print "<div class='status_item_right'>" . $lstmessages[$i]->getContentOfMessages() . "</div>";
                       	 	print "</div>";
                        }
                        ?>                      
                    </div>
                </div>

                <div class="right_content">
                    <div class="title_friend">Friend list</div>
                    <div class="friend_list">
                        <table class="table_friend">
                            <?php
                            require_once '../dao/connectiondao.php';
                            require_once '../dto/connectiondto.php';
                            $lstConnect = connectiondao::getConnectFromConnectionByID($_SESSION["Name"]);
                            for ($i = 0; $i < count($lstConnect); $i++) {
                                $link = "FriendInformation.php?userid=" . $lstConnect[$i]->getConnectedUserID();
                                print"<tr>";
                                print"<td class='row_friend'><a href='" . $link . "'>" . $lstConnect[$i]->getConnectedUserID() . "</a></td>";
                                print"<td class='row_online'>" . "</td>";
                                print"</tr>";
                            }
                            ?>
                        </table>
                    </div>
                    <div class="footer_friend"></div>
                </div>
            </div>      
        </div>
    </body>
</html>
